package com.openbravo.pos.inventory;

import com.openbravo.basic.BasicException;
import com.openbravo.data.user.DirtyManager;
import com.openbravo.data.user.EditorRecord;
import com.openbravo.format.Formats;
import com.openbravo.pos.forms.AppLocal;

import java.awt.Component;
import java.util.UUID;

import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.GroupLayout.ParallelGroup;
import javax.swing.GroupLayout.SequentialGroup;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.LayoutStyle;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.text.Document;

public class AttributeSetsEditor extends JPanel
  implements EditorRecord
{
  private Object id;
  private JLabel jLabel2;
  private JTextField m_jName;

  public AttributeSetsEditor(DirtyManager paramDirtyManager)
  {
    initComponents();
    this.m_jName.getDocument().addDocumentListener(paramDirtyManager);
    writeValueEOF();
  }

  public void writeValueEOF()
  {
    this.id = null;
    this.m_jName.setText(null);
    this.m_jName.setEnabled(false);
  }

  public void writeValueInsert()
  {
    this.id = UUID.randomUUID().toString();
    this.m_jName.setText(null);
    this.m_jName.setEnabled(true);
  }

  public void writeValueDelete(Object paramObject)
  {
    Object[] arrayOfObject = (Object[])(Object[])paramObject;
    this.id = arrayOfObject[0];
    this.m_jName.setText(Formats.STRING.formatValue(arrayOfObject[1]));
    this.m_jName.setEnabled(false);
  }

  public void writeValueEdit(Object paramObject)
  {
    Object[] arrayOfObject = (Object[])(Object[])paramObject;
    this.id = arrayOfObject[0];
    this.m_jName.setText(Formats.STRING.formatValue(arrayOfObject[1]));
    this.m_jName.setEnabled(true);
  }

  public Object createValue()
    throws BasicException
  {
    Object[] arrayOfObject = new Object[2];
    arrayOfObject[0] = this.id;
    arrayOfObject[1] = this.m_jName.getText();
    return arrayOfObject;
  }

  public Component getComponent()
  {
    return this;
  }

  public void refresh()
  {
  }

  private void initComponents()
  {
    this.jLabel2 = new JLabel();
    this.m_jName = new JTextField();
    this.jLabel2.setText(AppLocal.getIntString("Label.Name"));
    GroupLayout localGroupLayout = new GroupLayout(this);
    setLayout(localGroupLayout);
    localGroupLayout.setHorizontalGroup(localGroupLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addGap(0, 316, 32767).addGroup(localGroupLayout.createSequentialGroup().addContainerGap().addComponent(this.jLabel2, -2, 80, -2).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(this.m_jName, -2, 200, -2).addContainerGap()));
    localGroupLayout.setVerticalGroup(localGroupLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addGap(0, 43, 32767).addGroup(localGroupLayout.createSequentialGroup().addContainerGap().addGroup(localGroupLayout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(this.jLabel2).addComponent(this.m_jName, -2, -1, -2)).addContainerGap(-1, 32767)));
  }
}

/* Location:           D:\PowerFulPOS-2.30.2\openbravopos.jar
 * Qualified Name:     com.openbravo.pos.inventory.AttributeSetsEditor
 * JD-Core Version:    0.6.0
 */